{-# OPTIONS -Wall #-}

--------------------------------------------------------------------------------
-- |
-- Module      :  P5Hs.Language.Syntax
-- Copyright   :  (c) Stephen Tetley 2014
-- License     :  BSD3
--
-- Maintainer  :  stephen.tetley@gmail.com
-- Stability   :  unstable
-- Portability :  GHC
--
-- Syntax.
-- 
--------------------------------------------------------------------------------

module P5Hs.Language.Syntax
 


  where

import Data.Fixed


type Decimal = Fixed E9


-- In Java IF is a stmt not an expression.

-- Sunroof has a comment statement constructor - useful for 
-- passing comments through to generated code.

-- Sunroof doesn\'t have Seq of statements, but it seems 
-- essential Processing.


data Stmt = IfStmt Expr Stmt Stmt
          | Seq    [Stmt]
  deriving (Eq,Ord,Show)        


data Expr = Value  Value
          | VarId  String
          | Unary  UnaryOp Expr
          | Binary BinOp   Expr Expr
  deriving (Eq,Ord,Show)

data Value = Int    Integer
           | Float  Decimal
           | Double Decimal
           | Colour Colour
           | String String
  deriving (Eq,Ord,Show)           

data UnaryOp = LOGICAL_NOT
             | UPLUS
             | UMINUS
  deriving (Eq,Ord,Show)

data BinOp = ADDITION
           | MINUS
           | MULTIPLY
           | DIVIDE
           | MODULO
           | LOGICAL_AND
           | LOGICAL_OR
  deriving (Eq,Ord,Show)

data RelOp = EQUALITY
           | INEQUAITY
           | LESS_THAN
           | GREATER_THAN
           | LESS_THAN_EQ
           | GREATER_THAN_EQ
  deriving (Eq,Ord,Show)           

-- | /Processing Colour/ - dynamically typed - Expr should be Int.
--
-- (For now ignore colour mode)
--
data Colour = RGB   Expr Expr Expr
            | RGBA  Expr Expr Expr Expr
            | Gray  Expr
            | GrayA Expr Expr
  deriving (Eq,Ord,Show)